package com.markchu.web.structure.vo;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.markchu.common.utils.HttpServletUtil;
import com.markchu.modules.system.domain.User;
import lombok.Data;
import org.hibernate.annotations.NotFound;
import org.hibernate.annotations.NotFoundAction;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.util.StringUtils;

import javax.persistence.*;
import javax.servlet.http.HttpServletRequest;
import java.io.Serializable;
import java.util.Date;

@Data
public class UploadVo implements Serializable {
    private Long id;
    /** 文件名 */
    private String name;
    /** 文件路径 */
    private String path;
    /** 文件类型 */
    private String mime;
    /** 文件大小 */
    private Long size;
    /** 文件md5值 */
    private String md5;
    /** 文件sha1值 */
    private String sha1;
    private String remark;
    private Long acId;
    private Long userId;

    private Long clicks;
    private Long fileType;
    private Long status;
    /** 创建时间 */
    private Date createDate;
    private String userNickName;

    private String userThum;

    /**
     * 获取文件绝对路径
     */
    public String getUrl() {
        if (!StringUtils.isEmpty(path)) {
//			StringBuffer url = request.getRequestURL();
//			String baseUrl = url.delete(url.length() - request.getRequestURI().length(), url.length())
//					.append(request.getContextPath()).toString();
            return "/upload_pic" + path;
        }
        return path;
    }
}
